<template>
  <!-- <div><van-nav-bar left-arrow /></div> -->
  <div class="log_sty">
    <div>
      <van-nav-bar left-arrow title="安全认证"   @click-left="$router.go(-1)" />
    </div>
  
    <div con>
      <div>
        <p>1.请上传用户本人的微信收款码</p>

        <van-uploader
          v-model="wxPic"
          name="wxPic"
          accept="image/jpg, image/jpeg,image/png"
          :after-read="afterRead"
          preview-image
          :max-count="1"
          preview-full-image
          upload-text="微信收款码"
        />
      </div>
      <div>
        <p>2.请上传用户本人的支付宝收款码</p>

        <van-uploader
          v-model="zfbPic"
          name="zfbPic"
           accept="image/jpg, image/jpeg,image/png"
          :after-read="afterRead"
          preview-image
          :max-count="1"
          preview-full-image
          upload-text="支付宝收款码"
        />
      </div>
      <div>
        <p>支付宝账户：</p>

        <van-cell-group>
          <van-field v-model="zfb" placeholder="请输入您的支付宝账户 " />
        </van-cell-group>
      </div>
      <div>
        <p>3.请上传用户本人的USDT收款码</p>

        <van-uploader
          v-model="USDTPic"
          name="USDTPic"
           accept="image/jpg, image/jpeg,image/png"
          :after-read="afterRead"
          preview-image
          :max-count="1"
          preview-full-image
          upload-text="USDT收款码"
        />
      </div>
      <div>
        <p>USDT地址：</p>

        <van-cell-group>
          <van-field v-model="USDT" placeholder="请输入用户名" />
        </van-cell-group>
      </div>

      <div class="but_sty sms_sty_o">
        <van-button type="primary" @click="next">下一步</van-button>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "login",
  data() {
    return {
      USDT: "",
      zfb: "",
      wxPic: [],
      zfbPic: [],
      USDTPic: [],
      wechat_number:'',
      alpay_number:'',
      usdt_number:'',

    };
  },
  mounted() { 
   let that=this;
    that.base.head_status(1)
  },
  methods: {
    afterRead(file, detail) {
        var that=this;
    if(file.file.size > 10485760){
         that.$toast({ message:"请上传小一点的图片", position: "bottom" });
        return
    }
    
    console.log(file)
    var data={file:file.content};

 
     that._API.upload(data).then(res => {
         if(res.code){
                if(detail.name=="wxPic"){
                    that.wechat_number=res.data
                }else if(detail.name=="zfbPic"){
                    that.alpay_number=res.data
                }else if(detail.name=="USDTPic"){
                    that.usdt_number=res.data
                }
         }
          that.$toast({ message: res.msg, position: "bottom" });
     }).catch(err => {
          console.log("err", err);
    });
     
    },
    next() {
        let that=this;

    if(!that.base.empty_b(that.wechat_number)&&!that.base.empty_b(that.alpay_number)&&!that.base.empty_b(that.usdt_number)){
        return  that.$toast({ message: '微信支付宝USDT收款码至少上传一张作为您的收款方式', position: "bottom" });
    }
 
      var data = {
          alpay_number:that.base.empty_b(that.alpay_number)?that.baseURL+that.alpay_number:'',
          wechat_number:that.base.empty_b(that.wechat_number)?that.baseURL+that.wechat_number:'',
          usdt_number:that.base.empty_b(that.usdt_number)?that.baseURL+that.usdt_number:'',
            usdt_addr: that.USDT,
          alipayaccount: that.zfb,
          token:JSON.parse(localStorage.userinfo).token
      };
    
      that._API
        .getAttestation(data)
        .then(res => {
          if (res.code == 200) {
             this.$router.push({ name: 'auth_code'})
              // this.$router.push({ name: 'setting_pwd'})
          }
          that.$toast({ message: res.msg, position: "bottom" });
        })
        .catch(err => {
          console.log("err", err);
        });

      //  this.$router.push({ name: 'setting_pwd'})
      // return
    },

    log_author() {}
  }
};
</script>


<style lang="scss" scoped >
    /deep/.van-nav-bar{background-color: initial;}
    /deep/.van-nav-bar .van-icon, /deep/.van-uploader__upload-text,/deep/.van-field__control::-webkit-input-placeholder,/deep/.van-field__control,/deep/.van-nav-bar__title{color:white}

    .log_sty [title]{text-align: center;font-size: 1rem;}

    .log_sty [con]{padding-left: 12%;}

    .log_sty [con]>div>p{margin: 1rem 0;}
    /deep/.van-uploader__upload{background-color: #453362;border: 0;}
    /deep/.van-cell{    background-color: #453362;    border-radius: 1.5rem;}
    /deep/.van-cell-group{background-color: #453362;    width: 85%;    border-radius: 1.5rem;}
    .but_sty{    padding: 1rem 0 3rem;}
    .but_sty button{width: 85%;border: 0;border-radius: 0.5rem;    border-radius: 2rem;} 
    .but_sty .van-button--primary{background: #831BFA;}
</style>
